<!--应用程序入口模块-->
<template>
  <div id="app">
    <transition :name="ui.trans">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </transition>
  </div>
</template>

<script>

  export default {
    name: 'app',
    //存放VM
    data() {
      return {
        //VM最好能将UI和业务分开
        model: {},
        ui: {
          trans: 'left'
        }
      }
    },
    //VM监视器
    watch: {
      '$route'(to, from) {
        const toDepth = to.path.split('/').length
        const fromDepth = from.path.split('/').length
        if (toDepth == fromDepth)
          this.ui.trans = 'fade'
        else
          this.ui.trans = toDepth < fromDepth ? 'right' : 'left'

      }
    },
    //页面挂载后钩子
    mounted(){

    },
    //存放所有的方法
    methods: {}
  }
</script>

<style>
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
  }
</style>
